#include "gtest/gtest.h"
// #include <mockcpp/mokc.h>
// #include <mockcpp/mockcpp.hpp>

#include <vector>
#include <iostream>

#include "topoinfo_struct.h"
#include "log.h"
#include "checker_def.h"
#include "topo_meta.h"
#include "testcase_utils.h"
#include "coll_native_executor_base.h"
#include "hccl_aiv.h"
 #include "checker.h"
using namespace checker;
// using namespace hccl;

class AllGatherVTest : public testing::Test {
protected:
    static void SetUpTestCase()
    {
        std::cout << "AllGatherVTest set up." << std::endl;
    }

    static void TearDownTestCase()
    {
        std::cout << "AllGatherVTest tear down." << std::endl;
    }
    virtual void SetUp()
    {
        const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info();
        std::string caseName = "analysis_result_" + std::string(test_info->test_case_name()) + "_" + std::string(test_info->name());
        Checker::SetDumpFileName(caseName);
    }

    virtual void TearDown()
    {
        Checker::SetDumpFileName("analysis_result");
        // GlobalMockObject::verify();
        // 这边每个case执行完成需要清理所有的环境变量，如果有新增的环境变量，需要在这个函数中进行清理
        ClearHcclEnv();
    }
};

TEST_F(AllGatherVTest, all_gather_v_910B_opbase_varying_size_1)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 4);

    vector<u64> counts {1000000, 2000000, 3000000, 4000000};
    vector<u64> displs {0, 1000000, 3000000, 6000000};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshOpbaseExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_opbase_varying_size_2)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 4);

    vector<u64> counts {400000, 300000, 200000, 100000};
    vector<u64> displs {0, 400000, 700000, 900000};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshOpbaseExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, allgather_v_test)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 2);

    vector<u64> counts {40000, 30000, 20000, 10000};
    vector<u64> displs {0, 40000, 70000, 90000};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, allgather_v_AllGatherVMeshOpbaseExecutor_test)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 1);

    vector<u64> counts {400000, 300000, 200000, 100000};
    vector<u64> displs {0, 400000, 700000, 900000};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshOpbaseExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_opbase_varying_size_3)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 4);

    vector<u64> counts {200000, 400000, 600000, 800000};
    vector<u64> displs {0, 200000, 600000, 1200000};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshOpbaseExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_opbase_varying_size_4)
{

    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 4);

    vector<u64> counts {100000, 300000, 600000, 1200000};
    vector<u64> displs {0, 100000, 400000, 1000000};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshOpbaseExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_opbase_varying_size_5)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 5);

    vector<u64> counts {10000, 20000, 30000, 20000, 10000};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshOpbaseExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_opbase_varying_size_6)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 6);

    vector<u64> counts {10000, 20000, 30000, 30000, 20000, 10000};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshOpbaseExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_opbase_varying_size_7)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 7);

    vector<u64> counts {10000, 20000, 30000, 40000, 30000, 20000, 10000};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshOpbaseExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_offload_varying_size_1)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 1);

    vector<u64> counts {400000, 300000, 200000, 100000, 100, 200 ,300, 400};
    vector<u64> displs {0, 400000, 700000, 900000, 1000000, 1000100, 1000300, 1000600};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_offload_varying_size_2)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 2);

    vector<u64> counts {400000, 300000, 200000, 100000, 100, 200 ,300, 400};
    vector<u64> displs {0, 400000, 700000, 900000, 1000000, 1000100, 1000300, 1000600};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_offload_varying_size_3)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 3);

    vector<u64> counts {400000, 300000, 200000, 100000, 100, 200 ,300, 400};
    vector<u64> displs {0, 400000, 700000, 900000, 1000000, 1000100, 1000300, 1000600};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_offload_varying_size_4)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 4);

    vector<u64> counts {400000, 300000, 200000, 100000, 100, 200 ,300, 400};
    vector<u64> displs {0, 400000, 700000, 900000, 1000000, 1000100, 1000300, 1000600};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_offload_varying_size_5)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 5);

    vector<u64> counts {400000, 300000, 200000, 100000, 100, 200 ,300, 400};
    vector<u64> displs {0, 400000, 700000, 900000, 1000000, 1000100, 1000300, 1000600};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_offload_varying_size_6)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 6);

    vector<u64> counts {400000, 300000, 200000, 100000, 100, 200 ,300, 400};
    vector<u64> displs {0, 400000, 700000, 900000, 1000000, 1000100, 1000300, 1000600};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_offload_varying_size_7)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 7);

    vector<u64> counts {400000, 300000, 200000, 100000, 100, 200 ,300, 400};
    vector<u64> displs {0, 400000, 700000, 900000, 1000000, 1000100, 1000300, 1000600};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_910B_offload_varying_size_8)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 8);

    vector<u64> counts {400000, 300000, 200000, 100000, 100, 200 ,300, 400};
    vector<u64> displs {0, 400000, 700000, 900000, 1000000, 1000100, 1000300, 1000600};

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVMeshExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

// TEST_F(AllGatherVTest, all_gather_v_910B_AllGatherVMeshAIVExecutor)
// {
//     MOCKER(GetExternalInputHcclAivMode).stubs().will(returnValue(true));
//     RankTable_For_LLT gen;
//     TopoMeta topoMeta;
//     gen.GenTopoMeta(topoMeta, 1, 1, 7);

//     vector<u64> counts {10000, 20000, 30000, 40000, 30000, 20000, 10000};
//     vector<u64> displs {0};
//     for (auto i = 1; i < counts.size(); ++i) {
//             displs.emplace_back(displs[i-1] + counts[i-1]);
//     }

//     CheckerOpParam checkerOpParam;
//     checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
//     checkerOpParam.tag = "AllGatherV";
//     checkerOpParam.opMode = CheckerOpMode::OPBASE;
//     checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
//     checkerOpParam.VDataDes.counts = counts;
//     checkerOpParam.VDataDes.displs = displs;
//     checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
//     checkerOpParam.algName = "AllGatherVMeshAivExecutor";

//     Checker checker;
//     HcclResult ret;
//     ret = checker.Check(checkerOpParam, topoMeta);
// }

// TEST_F(AllGatherVTest, all_gather_v_910B_opbase_mesh_small_count_aiv)
// {
//     MOCKER(GetExternalInputHcclAivMode).stubs().will(returnValue(true));
//     RankTable_For_LLT gen;
//     TopoMeta topoMeta;
//     gen.GenTopoMeta(topoMeta, 1, 1, 7);

//     vector<u64> counts{10000, 20000, 30000, 40000, 30000, 20000, 10000};
//     vector<u64> displs{0};
//     for (auto i = 1; i < counts.size(); ++i) {
//             displs.emplace_back(displs[i - 1] + counts[i - 1]);
//     }

//     CheckerOpParam checkerOpParam;
//     checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
//     checkerOpParam.tag = "AllGatherV";
//     checkerOpParam.opMode = CheckerOpMode::OPBASE;
//     checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
//     checkerOpParam.VDataDes.counts = counts;
//     checkerOpParam.VDataDes.displs = displs;
//     checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
//     checkerOpParam.algName = "AllGatherVMeshAivSmallCountExecutor";

//     Checker checker;
//     HcclResult ret;
//     ret = checker.Check(checkerOpParam, topoMeta);
// }

// TEST_F(AllGatherVTest, all_gather_v_910B_AllGatherVMeshAivSmallCountExecutor)
// {
//     MOCKER(hccl::ClearAivSyncBuf).stubs().will(returnValue(HCCL_SUCCESS));
//     MOCKER(GetExternalInputHcclAivMode).stubs().will(returnValue(true));
//     RankTable_For_LLT gen;
//     TopoMeta topoMeta;
//     gen.GenTopoMeta(topoMeta, 1, 1, 7);

//     vector<u64> counts {100, 200, 300, 400, 300, 200, 100};
//     vector<u64> displs {0};
//     for (auto i = 1; i < counts.size(); ++i) {
//             displs.emplace_back(displs[i-1] + counts[i-1]);
//     }

//     CheckerOpParam checkerOpParam;
//     checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
//     checkerOpParam.tag = "AllGatherV";
//     checkerOpParam.opMode = CheckerOpMode::OPBASE;
//     checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
//     checkerOpParam.VDataDes.counts = counts;
//     checkerOpParam.VDataDes.displs = displs;
//     checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
//     checkerOpParam.algName = "AllGatherVMeshAivSmallCountExecutor";

//     Checker checker;
//     HcclResult ret;
//     ret = checker.Check(checkerOpParam, topoMeta);
// }

TEST_F(AllGatherVTest, all_gather_v_91093_AlignedAllGatherVDoubleRingFor91093Executor_multiSuperPod)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 2, 2, 4);

    vector<u64> counts {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 100, 100};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam  checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910_93;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AlignedAllGatherVDoubleRingFor91093Executor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_91093_AlignedAllGatherVDoubleRingFor91093Executor_multiServer)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 4);

    vector<u64> counts {100, 200, 300, 400, 500, 600, 700, 800};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam  checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910_93;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AlignedAllGatherVDoubleRingFor91093Executor";
    checkerOpParam.aicpuUnfoldMode = true;

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_91093_AllGatherVRingFor91093Executor_multiSuperPod)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 2, 2, 4);

    vector<u64> counts {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 100, 100};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam  checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910_93;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVRingFor91093Executor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_91093_AllGatherVRingFor91093Executor_multiServer)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 4);

    vector<u64> counts {100, 200, 300, 400, 500, 600, 700, 800};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam  checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910_93;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVRingFor91093Executor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_91093_AllGatherVRingFor91093Executor_singleServer)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 4);

    vector<u64> counts {100, 200, 300, 400};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam  checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910_93;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVRingFor91093Executor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}

TEST_F(AllGatherVTest, all_gather_v_91093_AllGatherVSemiRingExecutor_singleServer)
{
    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 2, 4);

    vector<u64> counts {100, 100, 100, 100, 100, 100, 100, 100};
    vector<u64> displs {0};
    for (auto i = 1; i < counts.size(); ++i) {
            displs.emplace_back(displs[i-1] + counts[i-1]);
    }

    CheckerOpParam  checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLGATHER_V;
    checkerOpParam.tag = "AllGatherV";
    checkerOpParam.opMode = CheckerOpMode::OFFLOAD;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910_93;
    checkerOpParam.VDataDes.counts = counts;
    checkerOpParam.VDataDes.displs = displs;
    checkerOpParam.VDataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllGatherVSemiRingExecutor";

    Checker checker;
    HcclResult ret;
    ret = checker.Check(checkerOpParam, topoMeta);
    EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
}